#ifndef GAME_H
#define GAME_H

#include "Singleton.h"

#include <QDebug>
#include <QList>
#include <QMap>
#include <exception>

class MyWidget;

class DialogDirector {
public:
    virtual ~DialogDirector(){}
    virtual void WidgetChanged(MyWidget*) = 0;

protected:
    DialogDirector(){}
    virtual void CreateWidgets() = 0;
};

class MyWidget {
  public:
    MyWidget(DialogDirector* d){ _director = d; }
    virtual void Changed(){ qInfo() << "MyWidget" << __FUNCTION__; }
    virtual void Handle(){
        _director->WidgetChanged(this);
    }
private:
    DialogDirector* _director;
};

class MyButton: public MyWidget {
  public:
    MyButton(DialogDirector* d)
        :MyWidget(d){ _director = d; }
    virtual void Changed(){ qInfo() << "MyButton" << __FUNCTION__; }
    virtual void Handle(){
        _director->WidgetChanged(this);
    }
private:
    DialogDirector* _director;
};

class FontDialogDirector: public DialogDirector {
  public:
    FontDialogDirector(){}
    virtual ~FontDialogDirector(){}
    virtual void WidgetChanged(MyWidget* theChangedWidget) {
        if(theChangedWidget == _mywidget) {
            qInfo() << "FontDialogDirector" << __FUNCTION__ << "-MyWidget";
        }
        else if(theChangedWidget == _mybutton) {
            qInfo() << "FontDialogDirector" << __FUNCTION__ << "-MyButton";
//            _mywidget->Print();
        }
    }
    virtual void Test1() { return _mywidget->Handle(); }
    virtual void Test2() { return _mybutton->Handle(); }

    virtual void CreateWidgets() {
        _mywidget = new MyWidget(this);
        _mybutton = new MyButton(this);
    }
private:
    MyWidget* _mywidget;
    MyButton* _mybutton;
};



#endif // GAME_H
